package com.fredhat.tvshowrenamer.parser.tvcom;

import java.util.*;

import com.fredhat.tvshowrenamer.TVShow;
import com.fredhat.tvshowrenamer.TVShowEpisode;

public class TVComCache {
	private static Hashtable<Object[], TVComEpisode> episodesByAirdate;
	private static Hashtable<Object[], TVComEpisode> episodesByEpisodeID;
	
	public TVComCache() {
		if (episodesByAirdate == null)
			episodesByAirdate = new Hashtable<Object[], TVComEpisode>();
		if (episodesByEpisodeID == null)
			episodesByEpisodeID = new Hashtable<Object[], TVComEpisode>();
	}
	
	public TVComEpisode getTVComEpisodeByAirdate(TVShow tvShow, Calendar airdate) {
		return episodesByAirdate.get(new Object[]{tvShow, airdate});
	}
	
	public void setTVComEpisodeByAirdate(TVShow tvShow, Calendar airdate, 
			TVComEpisode episode) {
		episodesByAirdate.put(new Object[]{tvShow, airdate}, episode);
	}
	
	public TVComEpisode getTVComEpisodeByShowEpisode(TVShow tvShow, int seasonNumber, 
			int episodeNumber) {
		return episodesByEpisodeID.get(new Object[]{tvShow, seasonNumber, episodeNumber});
	}
	
	public void setTVComEpisodeByShowEpisode(TVShow tvShow, TVComEpisode tvComEpisode) {
		episodesByEpisodeID.put(new Object[]{tvShow, tvComEpisode.getSeasonNumber(),
				tvComEpisode.getEpisodeNumber()}, tvComEpisode);
	}
}
